package net.internet;

import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.util.Enumeration;

public class GetInet
{
	public static void main(String[] args) throws IOException
	{
		try
		{
			InetAddress[] address = InetAddress.getAllByName("www.taobao.com");
			for (int i = 0; i < address.length; i++)
			{
				System.out.println(address[i]);
				System.out.println(address[i].isAnyLocalAddress());
			}
			InetAddress local = InetAddress.getLocalHost();
			NetworkInterface.getByInetAddress(local);
			System.out.println(local.isReachable(1100));
			Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
			while (networkInterfaces.hasMoreElements())
			{
				NetworkInterface networkInterface = (NetworkInterface) networkInterfaces.nextElement();
				System.out.println(networkInterface);
			}
		}
		catch (UnknownHostException e)
		{
			e.printStackTrace();
		}
		
	}
}
